package com.xiaoyi.intentsdklibrary.SDK.FloatView;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v4.internal.view.SupportMenu;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import com.xiaoyi.intentsdklibrary.Bean.ViewBean;
import java.util.List;

public class NoteInfoView extends View {
    private float mClickX = 0.0f;
    private float mClickY = 0.0f;
    private Context mContext;
    private Paint mPaint;
    private Paint mPaintColor;
    private Paint mPaintListView;
    private List<ViewBean> mViewBeanList;

    public NoteInfoView(Context context) {
        super(context);
        this.mContext = context;
        setFocusable(true);
        setFocusableInTouchMode(true);
        Paint paint = new Paint();
        this.mPaint = paint;
        paint.setStrokeWidth(1.0f);
        this.mPaint.setColor(-65536);
        this.mPaint.setAntiAlias(true);
        this.mPaint.setStyle(Paint.Style.STROKE);
        this.mPaint.setStrokeCap(Paint.Cap.ROUND);
        this.mPaint.setStrokeJoin(Paint.Join.ROUND);
        Paint paint2 = new Paint();
        this.mPaintListView = paint2;
        paint2.setStrokeWidth(2.0f);
        this.mPaintListView.setColor(-16776961);
        this.mPaintListView.setAntiAlias(true);
        this.mPaintListView.setStyle(Paint.Style.STROKE);
        this.mPaintListView.setStrokeCap(Paint.Cap.ROUND);
        this.mPaintListView.setStrokeJoin(Paint.Join.ROUND);
        Paint paint3 = new Paint();
        this.mPaintColor = paint3;
        paint3.setColor(-16776961);
        this.mPaintColor.setAlpha(100);
        this.mPaintColor.setStyle(Paint.Style.FILL);
    }

    public NoteInfoView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    /* access modifiers changed from: protected */
    public void onDraw(Canvas canvas) {
        int width = 0;
        int height = 0;
        super.onDraw(canvas);
        List<ViewBean> list = this.mViewBeanList;
        if (list != null) {
            int i = 0;
            ViewBean viewBean = null;
            for (ViewBean viewBean2 : list) {
                Rect rect = viewBean2.getRect();
                if (this.mClickX >= ((float) rect.left) && this.mClickX <= ((float) rect.right) && this.mClickY >= ((float) rect.top) && this.mClickY <= ((float) rect.bottom)) {
                    if (i == 0) {
                        width = rect.width();
                        height = rect.height();
                    } else if (i > rect.width() * rect.height()) {
                        width = rect.width();
                        height = rect.height();
                    }
                    i = width * height;
                    viewBean = viewBean2;
                }
            }
            for (ViewBean viewBean3 : this.mViewBeanList) {
                Rect rect2 = viewBean3.getRect();
                float f = this.mClickX;
                if (f == 0.0f && f == 0.0f) {
                    canvas.drawRect(rect2, this.mPaint);
                } else if (viewBean == viewBean3) {
                    canvas.drawRect(rect2, this.mPaintColor);
                    NoteInfoViewSDK.getInstance().showChoseView(this.mContext, this.mViewBeanList, viewBean);
                } else {
                    canvas.drawRect(rect2, this.mPaint);
                }
            }
        }
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        this.mClickX = motionEvent.getX();
        this.mClickY = motionEvent.getY();
        invalidate();
        return super.onTouchEvent(motionEvent);
    }

    public void setPath(List<ViewBean> list) {
        this.mClickX = 0.0f;
        this.mClickY = 0.0f;
        this.mViewBeanList = list;
        invalidate();
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4) {
            return super.onKeyDown(i, keyEvent);
        }
        NoteInfoViewSDK.getInstance().hide();
        return true;
    }
}
